package com.d3works.apps.purchase.service.config;

import com.d3works.apps.base.db.Company;
import com.d3works.apps.purchase.db.PurchaseConfig;
import com.d3works.apps.purchase.exception.PurchaseExceptionMessage;
import com.d3works.exception.D3worksException;
import com.d3works.exception.db.repo.TraceBackRepository;
import com.d3works.i18n.I18n;

public class PurchaseConfigService {

  public PurchaseConfig getPurchaseConfig(Company company) throws D3worksException {

    PurchaseConfig purchaseConfig = company.getPurchaseConfig();

    if (purchaseConfig == null) {
      throw new D3worksException(
          TraceBackRepository.CATEGORY_CONFIGURATION_ERROR,
          I18n.get(PurchaseExceptionMessage.PURCHASE_CONFIG_1),
          company.getName());
    }

    return purchaseConfig;
  }
}
